﻿#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License, as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using ExtremeML.Core;

namespace ExtremeML.Spreadsheet
{
	// This is a partial class that adds custom functionality to its auto-generated partner.
	public sealed partial class StylesheetWrapper
	{
		#region Custom Properties


		#endregion
		#region Custom Methods

		/// <summary>
		/// Returns the primary (Normal) font used by this workbook.
		/// </summary>
		/// <returns>A <see cref="FontWrapper"/> that represents the designated Normal font.</returns>
		internal FontWrapper GetNormalFont()
		{
			var cellStyle = CellStyles.CellStyles.Find("Normal");

			if (cellStyle != null && cellStyle.FormatId.HasValue)
			{
				var cellStyleFormat = CellStyleFormats.CellFormats[(int)cellStyle.FormatId.Value];

				if (cellStyleFormat.FontId.HasValue)
				{
					return Fonts.Fonts[(int)cellStyleFormat.FontId.Value];
				}
			}

			throw new PackageException("The template does not contain a resolvable Normal font.");
		}

		#endregion
		#region Overrides


		#endregion
		#region Implementation Methods


		#endregion
		#region Static Methods


		#endregion
	}
}
